function timer(time) { $('.promotion .timer').removeClass('end'); let countDownDate = new Date(time).getTime(); //let x = setInterval(function() { // Get today's date and time let now = new Date().getTime(); // Find the distance between now and the count down date let distance = countDownDate - now; if (distance < 1000 * 60 * 60) $('.promotion .timer').addClass('end'); // Time calculations for days, hours, minutes and seconds let days = Math.floor(distance / (1000 * 60 * 60 * 24)); let hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)); let minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60)); let seconds = Math.floor((distance % (1000 * 60)) / 1000); $('.promotion .days').html(timerItem(days)); $('.promotion .hours').html(timerItem(hours)); $('.promotion .minutes').html(timerItem(minutes)); // If the count down is finished, write some text //if (distance < 0) { // clearInterval(x); //} //}, 10000000); } $( document ).ready( function (){ $('.promotion .tabs a').on('click touchstart', function () { if (!$(this).hasClass('active')) { $('.promotion .tabs a').removeClass('active'); $(this).addClass('active'); let page = $(this).data('page'); $('.promotion .content .list').css('display', 'none'); $(`.promotion .content .list.${page}`).css('display', 'block'); } }); $('.promotion .close').on('click touchstart', function (e) { e.preventDefault(); e.stopPropagation(); $('.promotion').css('display', 'none'); }); })